package com.cykj.order.domain.event;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单状态变更事件
 * 
 * @author cykj
 * @date 2025-08-20
 */
public class OrderStatusChangeEvent implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    /** 订单ID */
    private Long orderId;
    
    /** 订单号 */
    private String orderNumber;
    
    /** 用户ID */
    private Long userId;
    
    /** 店铺ID */
    private Long shopId;
    
    /** 原状态 */
    private Integer oldStatus;
    
    /** 新状态 */
    private Integer newStatus;
    
    /** 订单金额 */
    private BigDecimal totalAmount;
    
    /** 用户手机号 */
    private String userPhone;
    
    /** 配送地址 */
    private String deliveryAddress;
    
    /** 事件时间戳 */
    private Long timestamp;
    
    /** 操作人（可选：管理员ID、店铺ID等） */
    private String operator;
    
    /** 备注信息 */
    private String remark;

    public OrderStatusChangeEvent() {
        this.timestamp = System.currentTimeMillis();
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public String getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(String orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public Integer getOldStatus() {
        return oldStatus;
    }

    public void setOldStatus(Integer oldStatus) {
        this.oldStatus = oldStatus;
    }

    public Integer getNewStatus() {
        return newStatus;
    }

    public void setNewStatus(Integer newStatus) {
        this.newStatus = newStatus;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public String getUserPhone() {
        return userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public String getDeliveryAddress() {
        return deliveryAddress;
    }

    public void setDeliveryAddress(String deliveryAddress) {
        this.deliveryAddress = deliveryAddress;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * 获取状态描述
     */
    public String getOldStatusDesc() {
        return getStatusDesc(this.oldStatus);
    }

    public String getNewStatusDesc() {
        return getStatusDesc(this.newStatus);
    }

    private String getStatusDesc(Integer status) {
        if (status == null) return "未知";
        
        switch (status) {
            case 0: return "待支付";
            case 1: return "已支付待接单";
            case 2: return "已接单制作中";
            case 3: return "配送中";
            case 4: return "已完成";
            case 5: return "已取消";
            case 6: return "已退款";
            default: return "未知状态";
        }
    }

    @Override
    public String toString() {
        return "OrderStatusChangeEvent{" +
                "orderId=" + orderId +
                ", orderNumber='" + orderNumber + '\'' +
                ", userId=" + userId +
                ", shopId=" + shopId +
                ", oldStatus=" + oldStatus +
                ", newStatus=" + newStatus +
                ", totalAmount=" + totalAmount +
                ", userPhone='" + userPhone + '\'' +
                ", deliveryAddress='" + deliveryAddress + '\'' +
                ", timestamp=" + timestamp +
                ", operator='" + operator + '\'' +
                ", remark='" + remark + '\'' +
                '}';
    }
}
